home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / fax / src / libtiff / tiffcomp.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  6KB  |  210 lines

  1. /* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffcomp.h,v 1.32 92/10/30 11:43:31 sam Rel $ */
  2.  
  3. /*
  4.  * Copyright (c) 1990, 1991, 1992 Sam Leffler
  5.  * Copyright (c) 1991, 1992 Silicon Graphics, Inc.
  6.  *
  7.  * Permission to use, copy, modify, distribute, and sell this software and 
  8.  * its documentation for any purpose is hereby granted without fee, provided
  9.  * that (i) the above copyright notices and this permission notice appear in
  10.  * all copies of the software and related documentation, and (ii) the names of
  11.  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  12.  * publicity relating to the software without the specific, prior written
  13.  * permission of Sam Leffler and Silicon Graphics.
  14.  * 
  15.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  16.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  17.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  18.  * 
  19.  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  20.  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  21.  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  22.  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  23.  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  24.  * OF THIS SOFTWARE.
  25.  */
  26.  
  27. #ifndef _COMPAT_
  28. #define    _COMPAT_
  29. /*
  30.  * This file contains a hodgepodge of definitions and
  31.  * declarations that are needed to provide compatibility
  32.  * between the native system and the base implementation
  33.  * that the library assumes.
  34.  *
  35.  * NB: This file is a mess.
  36.  */
  37.  
  38. /*
  39.  * If nothing has been specified about the use of function prototypes,
  40.  * deduce it's use from thje compilation environment.  Note that if
  41.  * we decide protototypes should be used, we also assume that const is
  42.  * supported.  If this is not true, then the user must force the
  43.  * definitions in the Makefile or similar.
  44.  */
  45. #if !defined(USE_PROTOTYPES)
  46. #if defined(__STDC__) || defined(__EXTENDED__) || defined(c_plusplus) || defined(__cplusplus)
  47. #define    USE_PROTOTYPES    1
  48. #define    USE_CONST    1
  49. #endif /* __STDC__ || __EXTENDED__ || c_plusplus || __cplusplus */
  50. #endif /* !defined(USE_PROTOTYPES) */
  51.  
  52. /*
  53.  * If nothing has been specified about the
  54.  * use of const, define it to be void.
  55.  */
  56. #if !USE_CONST
  57. #if !defined(const)
  58. #define    const
  59. #endif
  60. #endif
  61.  
  62. /*
  63.  * Setup basic type definitions and function declaratations.
  64.  */
  65. #ifdef THINK_C
  66. #include <unix.h>
  67. #include <math.h>
  68. #endif
  69. #if USE_PROTOTYPES
  70. #include <stdio.h>
  71. #endif
  72. #ifdef applec
  73. #include <types.h>
  74. #else
  75. #ifndef THINK_C
  76. #include <sys/types.h>
  77. #endif
  78. #endif
  79. #ifdef VMS
  80. #include <file.h>
  81. #include <unixio.h>
  82. #else
  83. #include <fcntl.h>
  84. #endif
  85. #if defined(THINK_C) || defined(applec)
  86. #include <stdlib.h>
  87. typedef long off_t;
  88. #define    BSDTYPES
  89. #endif
  90.  
  91. /*
  92.  * Workarounds for BSD lseek definitions.
  93.  */
  94. #if defined(SYSV) || defined(VMS)
  95. #if defined(SYSV)
  96. #include <unistd.h>
  97. #endif
  98. #define    L_SET    SEEK_SET
  99. #define    L_INCR    SEEK_CUR
  100. #define    L_XTND    SEEK_END
  101. #endif /* defined(SYSV) || defined(VMS) */
  102. #ifndef L_SET
  103. #define L_SET    0
  104. #define L_INCR    1
  105. #define L_XTND    2
  106. #endif
  107.  
  108. /*
  109.  * The library uses memset, memcpy, and memcmp.
  110.  * ANSI C and System V define these in string.h.
  111.  */
  112. #include <string.h>
  113.  
  114. /*
  115.  * The BSD typedefs are used throughout the library.
  116.  * If your system doesn't have them in <sys/types.h>,
  117.  * then define BSDTYPES in your Makefile.
  118.  */
  119. #ifdef BSDTYPES
  120. typedef    unsigned char u_char;
  121. typedef    unsigned short u_short;
  122. typedef    unsigned int u_int;
  123. typedef    unsigned long u_long;
  124. #endif
  125.  
  126. /*
  127.  * Default Read/Seek/Write definitions.  These aren't really
  128.  * compatibility related and should probably go in tiffiop.h.
  129.  */
  130. #ifndef ReadOK
  131. #define    ReadOK(tif, buf, size) \
  132.     (TIFFReadFile(tif, (char *)buf, size) == size)
  133. #endif
  134. #ifndef SeekOK
  135. #define    SeekOK(tif, off) \
  136.     (TIFFSeekFile(tif, (long)off, L_SET) == (long)off)
  137. #endif
  138. #ifndef WriteOK
  139. #define    WriteOK(tif, buf, size) \
  140.     (TIFFWriteFile(tif, (char *)buf, size) == size)
  141. #endif
  142.  
  143. /*
  144.  * dblparam_t is the type that a double precision
  145.  * floating point value will have on the parameter
  146.  * stack (when coerced by the compiler).
  147.  */
  148. #ifdef applec
  149. typedef extended dblparam_t;
  150. #else
  151. typedef double dblparam_t;
  152. #endif
  153.  
  154. /*
  155.  * Varargs parameter list handling...YECH!!!!
  156.  */
  157. #if defined(__STDC__) && !defined(USE_VARARGS)
  158. #define    USE_VARARGS    0
  159. #endif
  160.  
  161. #if defined(USE_VARARGS)
  162. #if USE_VARARGS
  163. #include <varargs.h>
  164. #define    VA_START(ap, parmN)    va_start(ap)
  165. #else
  166. #include <stdarg.h>
  167. #define    VA_START(ap, parmN)    va_start(ap, parmN)
  168. #endif
  169. #endif /* defined(USE_VARARGS) */
  170.  
  171. /*
  172.  * Macros for declaring functions with and without
  173.  * prototypes--according to the definition of USE_PROTOTYPES.
  174.  */
  175. #if USE_PROTOTYPES
  176. #define    DECLARE1(f,t1,a1)        f(t1 a1)
  177. #define    DECLARE2(f,t1,a1,t2,a2)        f(t1 a1, t2 a2)
  178. #define    DECLARE3(f,t1,a1,t2,a2,t3,a3)    f(t1 a1, t2 a2, t3 a3)
  179. #define    DECLARE4(f,t1,a1,t2,a2,t3,a3,t4,a4)\
  180.     f(t1 a1, t2 a2, t3 a3, t4 a4)
  181. #define    DECLARE5(f,t1,a1,t2,a2,t3,a3,t4,a4,t5,a5)\
  182.     f(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5)
  183. #define    DECLARE6(f,t1,a1,t2,a2,t3,a3,t4,a4,t5,a5,t6,a6)\
  184.     f(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6)
  185. #define    DECLARE1V(f,t1,a1)        f(t1 a1 ...)
  186. #define    DECLARE2V(f,t1,a1,t2,a2)    f(t1 a1, t2 a2, ...)
  187. #define    DECLARE3V(f,t1,a1,t2,a2,t3,a3)    f(t1 a1, t2 a2, t3 a3, ...)
  188. #else
  189. #define    DECLARE1(f,t1,a1)        f(a1) t1 a1;
  190. #define    DECLARE2(f,t1,a1,t2,a2)        f(a1,a2) t1 a1; t2 a2;
  191. #define    DECLARE3(f,t1,a1,t2,a2,t3,a3)    f(a1, a2, a3) t1 a1; t2 a2; t3 a3;
  192. #define    DECLARE4(f,t1,a1,t2,a2,t3,a3,t4,a4) \
  193.     f(a1, a2, a3, a4) t1 a1; t2 a2; t3 a3; t4 a4;
  194. #define    DECLARE5(f,t1,a1,t2,a2,t3,a3,t4,a4,t5,a5)\
  195.     f(a1, a2, a3, a4, a5) t1 a1; t2 a2; t3 a3; t4 a4; t5 a5;
  196. #define    DECLARE6(f,t1,a1,t2,a2,t3,a3,t4,a4,t5,a5,t6,a6)\
  197.     f(a1, a2, a3, a4, a5, a6) t1 a1; t2 a2; t3 a3; t4 a4; t5 a5; t6 a6;
  198. #if USE_VARARGS
  199. #define    DECLARE1V(f,t1,a1) \
  200.     f(a1, va_alist) t1 a1; va_dcl
  201. #define    DECLARE2V(f,t1,a1,t2,a2) \
  202.     f(a1, a2, va_alist) t1 a1; t2 a2; va_dcl
  203. #define    DECLARE3V(f,t1,a1,t2,a2,t3,a3) \
  204.     f(a1, a2, a3, va_alist) t1 a1; t2 a2; t3 a3; va_dcl
  205. #else
  206. "Help, I don't know how to handle this case: !USE_PROTOTYPES and !USE_VARARGS?"
  207. #endif
  208. #endif
  209. #endif /* _COMPAT_ */
  210.